package requet

import (
	"PolarDay/common/setting"
	"strconv"

	"github.com/gin-gonic/gin"
)

// 分页请求条件
type RequetPaging struct {
	Size   int32          `json:"size"`
	Page   int32          `json:"page"`
	Sort   string         `json:"sort"`
	Filter map[string]any `json:"filter"`
}

// GetPage 获取每页数量
func GetPage(c *gin.Context) (page, pagesize int) {
	page, _ = strconv.Atoi(c.Query("page"))
	pagesize, _ = strconv.Atoi(c.Query("limit"))
	if pagesize == 0 {
		pagesize = setting.Config.App.PageSize
	}
	if page == 0 {
		page = 1
	}
	return
}
